home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <libraries/dos.h>
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
-
- #include <clib/alib_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/icon_protos.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- struct Library *IconBase=NULL;
- void sr(char *s);
-
- char source[200];
- char destination[200];
- char itype[200];
- UBYTE tooltype[102][100];
- char toolfilename[200];
- void InitTypes(char *s);
- UBYTE *tools[102];
-
- main(int argc,char *argv[])
- {
- char *s;
- int i;
- UBYTE mytype;
- struct DiskObject *src;
- struct DiskObject *dst;
- struct Gadget *srcgad;
- struct DiskObject new;
- BOOL success=FALSE;
- for(i=0;i<100;i++)
- tools[i]=&tooltype[i];
- if(argc!=2)
- {
- printf("TextObj version 1.0, written by Joseph Hodge\n");
- printf("usage: TextObj <source.txt>\n");
- printf(" ie: TextObj Serial.txt\n");
- printf("\n");
- printf("\n\n");
- exit(0);
- }
- strcpy(source,argv[1]);
- strcpy(destination,source);
- sr(source);
- sr(destination);
- InitTypes(source);
- i=strlen(destination)-1;
- while(i>=0)
- {
- if(destination[i]=='.') break;
- i--;
- }
- if(i) destination[i]='\0';
-
- IconBase=OpenLibrary("icon.library",0L);
- if(src=GetDiskObject(destination))
- {
-
- srcgad=(struct Gadget *)&src->do_Gadget;
- CopyMem(src,&new,sizeof(struct DiskObject));
- new.do_Gadget.Width=srcgad->Width;
- new.do_Gadget.Height=srcgad->Height;
- new.do_Gadget.Flags=srcgad->Flags;
- new.do_Gadget.Activation=srcgad->Activation;
- new.do_Gadget.GadgetType=srcgad->GadgetType;
- new.do_Gadget.GadgetRender=srcgad->GadgetRender;
- new.do_Gadget.SelectRender=srcgad->SelectRender;
- new.do_ToolTypes=(APTR)tools;
- new.do_Type= src->do_Type;
- PutDiskObject(destination,(struct DiskObject *)&new);
- FreeDiskObject(src);
- DeleteFile(source);
- }
- CloseLibrary(IconBase);
- exit(0);
- }
- void InitTypes(char *s)
- {
- FILE *fi;
- register int i=0;
- int j=0;
- char image[102];
- fi=fopen(s,"r");
- if(fi!=NULL)
- {
- while(fgets(image,100,fi)!=NULL && i<100)
- {
- sr(image); strcpy(&tooltype[i][0],image);
- i++;
- }
- fclose(fi);
- }
- tools[i]=NULL;
- }
- void sr(char *s)
- {
- register int i;
- i=strlen(s)-1;
- while(i>-1)
- {
- if(*(s+i)<=32) *(s+i)='\0'; else break;
- i--;
- }
- }
-